<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>xSite Administrator's Control Panel</title>
<link rel="stylesheet" href="./php.net.cn/xsite/admin/images/admincp.css" type="text/css" media="all" />
<meta content="xSite Inc." name="Copyright" />
<script src="php.net.cn/xsite/admin/js/common.js" type="text/javascript"></script>
</head>
<body>
<div id="append"></div>
<script type="text/javascript">
	function headermenu(ctrl) {
		ctrl.className = ctrl.className == 'otherson' ? 'othersoff' : 'otherson';
		var menu = document.getElementById('header_menu_body');
		if(!menu) {
			menu = document.createElement('div');
			menu.id = 'header_menu_body';
			menu.innerHTML = '<ul>' + document.getElementById('header_menu_menu').innerHTML + '</ul>';
			var obj = ctrl;
			var x = ctrl.offsetLeft;
			var y = ctrl.offsetTop;
			while((obj = obj.offsetParent) != null) {
				x += obj.offsetLeft;
				y += obj.offsetTop;
			}
			menu.style.left = x + 'px';
			menu.style.top = y + ctrl.offsetHeight + 'px';
			menu.className = 'togglemenu';
			menu.style.display = '';
			document.body.appendChild(menu);
		} else {
			menu.style.display = menu.style.display == 'none' ? '' : 'none';
		}
	}
	
</script>

<script type="text/javascript">
	function select_category() {
		 var category_list = document.getElementById("category_list");
		  window.location = category_list.options[category_list.selectedIndex].value;
	}
	
	var product_category = new Array();
	
	
  <?php foreach($system_tree_category as $k => $v) {?>
	  

	<?php if($v['module'] == 'product') {?> 
		product_category['<?=$k?>'] = '<?=$v['name']?>';
	  
		<?php if(is_array($v['subcategory']) && count($v['subcategory'])) foreach($v['subcategory'] as $kk => $vv){?>
			
			<?php if($vv['module'] == 'product') {?> 
				<?php if(!isset($vv['gourl']) || $vv['gourl'] == ''){?>
				
					product_category['<?=$kk?>'] = '  |----<?=$vv['name']?>';
					
					<?php if(is_array($vv['subcategory']) && count($vv['subcategory'])) foreach($vv['subcategory'] as $kkk => $vvv){?>
						
						<?php if($vvv['module'] == 'product') {?> 
						product_category['<?=$kkk?>'] = '  |    |----<?=$vvv['name']?>';
						<?php }?>
					<?php }?>
				
				<?php }?>
			<?php }?>
			
			
		<?php }?>
	<?php }?>

	  
  <?php }?>
		  

	
	function select_operation(f) {
		document.postform.new_category_id.length = 0; //初始化下拉列表 清空下拉数据
		document.postform.new_category_id.style.display = 'none';
		document.postform.keywords.style.display = 'none';
		if (f.options[f.selectedIndex].value == 'del') {
			//删除处理
		}
		if (f.options[f.selectedIndex].value == 'move') {
			document.postform.new_category_id.style.display = '';
			for (var i in product_category) {
				//alert(group_list[f.options[f.selectedIndex].value][i]);
				document.postform.new_category_id.options[document.postform.new_category_id.length] = new Option(product_category[i], i);
			}
		}
		//搜索
		if (f.options[f.selectedIndex].value == 'search') {
			document.postform.keywords.style.display = '';
			
		}
	}

</script>

<div class="container">
  
	<h3 class="marginbot">		
		<select name="category_list" onchange="select_category()" id="category_list">
		<option value="xsite.php?action=product&operation=list" >全部分类</option>
		<?php foreach($system_tree_category as $k => $v) {?>
				<?php if($v['module'] == 'product') {?> 
                	<option value="xsite.php?action=product&operation=list&category=<?=$k?>" <?php if(!empty($category) && $category == $k){?>selected="selected"<?php }?> ><?=$v['name']?></option>
					<?php if(is_array($v['subcategory']) && count($v['subcategory'])) foreach($v['subcategory'] as $kk => $vv){?>
                            <?php if($vv['module'] == 'product') {?> 
                            	<option value="xsite.php?action=product&operation=list&category=<?=$kk?>" <?php if(!empty($category) && $category == $kk){?>selected="selected"<?php }?> >&nbsp;&nbsp;|----<?=$vv['name']?></option>
								<?php if(is_array($vv['subcategory']) && count($vv['subcategory'])) foreach($vv['subcategory'] as $kkk => $vvv){?>
                                    <option value="xsite.php?action=product&operation=list&category=<?=$kkk?>" <?php if(!empty($category) && $category == $kkk){?>selected="selected"<?php }?> >&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;|----<?=$vvv['name']?></option>
                                <?php }?>
                            <?php }?>
                    <?php }?>
                <?php } ?>
		<?php }?>
		</select>
		
		<a href="xsite.php?action=product&operation=edit&category=<?=$category?>" class="sgbtn"><span>添加产品</span></a> 
		<?php if(!empty($category)){?>
		<a onClick="return confirm('此操作需要几分钟或更长时间，确定要进行吗？')"  href="xsite.php?action=product&operation=update_index&category=<?=$category?>" class="sgbtn"><span>更新该栏索引</span></a>
		<?php } else {?>
		<a onClick="return confirm('此操作需要几分钟或更长时间，确定要进行吗？')"  href="xsite.php?action=product&operation=update_all_index" class="sgbtn"><span>更新所有栏索引</span></a>
		<?php }?>
	</h3>
	
  <div class="note fixwidthdec">
    <p class="i">这里是产品内容列表。</p>
  </div>
  
  <div class="mainbox">
    <form id="postform" name="postform" method="post" action="xsite.php?action=product&operation=batch">
      <table class="inputlist">
        <tr>
          <? if(!empty($category)){?><th><label><input class="checkbox" type="checkbox" id="chkall" name="chkall" onClick="checkall(this.form);" /></label></th><?php }?>
		  <th nowrap="nowrap">标题</th>
          <th nowrap="nowrap">时间</th>
          <th nowrap="nowrap">缩略图</th>
		  <th nowrap="nowrap">审核</th>
          <th nowrap="nowrap">调到首页</th>
          <th nowrap="nowrap">编辑</th>
          <th nowrap="nowrap">删除</th>
        </tr>
        <?php if (is_array($list) && count($list) > 0) foreach ($list as $k => $v) {?>
		<tr>
          <? if(!empty($category)){?><td width="60"> <label><input name="product_key[]" class="checkbox" type="checkbox" value="<?=$v['key']?>" /></label></td><?php }?>
			<td><?php if(empty($category)){?>[<?=$system_category[$v['category']]['name']?>]<?php }?> <a target="_blank" href="http://<?=$site_url?><?=SITE_PATH?>/<?=(SITE_REWRITE ? '' : "?")?><?=$system_category[$v['category']]['detailed_tpl']?>/<?=$v['category']?>/<?=$v['key']?>.html"><?=str_sub($v['name'], 30, "…")?></a></td>
			<td width="120"><?=date("Y-m-d", $v['key'])?></td>
            <td width="60"><?php if(!empty($v['ptitle'])) {?>  <a href="<?=$v['ptitle']?>" target="_blank" >查看</a> <?php }else{?> 无图  <?php }?></td>
			<td width="60"><?php if(empty($v['pass']) || $v['pass'] == 4){?><a href="xsite.php?action=product&operation=pass&category=<?=$v['category']?>&key=<?=$v['key']?>&pass=1&page=<?=$page?>"><strong>开启</strong></a><?php } else {?><a href="xsite.php?action=product&operation=pass&category=<?=$v['category']?>&key=<?=$v['key']?>&pass=4&page=<?=$page?>">关闭</a><?php }?></td>
			<td width="80"><?php if(empty($v['status']) || $v['status'] == 1){?><a href="xsite.php?action=product&operation=headtopic&category=<?=$v['category']?>&key=<?=$v['key']?>&status=8&page=<?=$page?>"><strong>首页展示</strong></a><?php } else {?><a href="xsite.php?action=product&operation=headtopic&category=<?=$v['category']?>&key=<?=$v['key']?>&status=1&page=<?=$page?>">取消展示</a><?php }?></td>
			<td width="60"><a href="xsite.php?action=product&operation=edit&category=<?=$v['category']?>&key=<?=$v['key']?>&page=<?=$page?>">编辑</a></td>
			<td width="60"><a onClick="return confirm('确定删除？');" href="xsite.php?action=product&operation=del&category=<?=$v['category']?>&key=<?=$v['key']?>&page=<?=$page?>">删除</a></td>
        </tr>
		<?php }?>
      </table>
	  
	  
	  <? if(!empty($category)){?>
	  管理动作：
		<label>
		<select name="batch_action" id="batch_action" onChange="select_operation(this);">
		  <option value="0">----</option>
		  <option value="del">删除</option>
		  <option value="move">移动</option>
		  <option value="search">搜索</option>
		</select>
		</label>
		<label><select name="new_category_id" id="new_category_id" style="display:none"></select></label>
		<label><input name='keywords' class='txt' type='text' id='keywords' style="display:none" value='请输入关键词' />
		<input name="category" type="hidden" value="<?=$category?>">
		<input name="page" type="hidden" value="<?=$page?>">
		 <label><input type="submit" name="Submit" class="btn" value="提交" /></label>
		<?php }?>
		
	  </form>
	  
	  
      <div class="margintop"></div>
    
	
	<?php $m = $multipage;?>
	<?php if($m['total_row'] > $limit) {?>
	<div class="pages_btns">
		<div class="pages" style="margin-left: 5px;margin-top: 5px;">
			<em>&nbsp;<?=$m['total_row']?>&nbsp;</em>
			<a href="xsite.php?action=product&operation=list&category=<?=$category?>&page=1" class="first">1 ...</a>
			<a href="xsite.php?action=product&operation=list&category=<?=$category?>&page=<?=$m['up_page']?>" class="prev">&lsaquo;&lsaquo;</a>
			<?php if(count($m['link']))foreach($m['link'] as $k => $n) {?>
				<?php if ($n != $m['current_page']){?>
					<a href="xsite.php?action=product&operation=list&category=<?=$category?>&page=<?=$n?>"> <?=$n?> </a>
				<?php }else{ ?>
					<strong> <?=$n?> </strong>
				<?php } ?>
			<?php } ?>
			<a href="xsite.php?action=product&operation=list&category=<?=$category?>&page=<?=$m['next_page']?>" class="next">&rsaquo;&rsaquo;</a>
			<a href="xsite.php?action=product&operation=list&category=<?=$category?>&page=<?=$m['total_page']?>" class="last">... <?=$m['total_page']?></a>
			<kbd>
				<input type="text" name="custompage" size="3" onKeyDown="if(event.keyCode==13) {window.location='xsite.php?action=product&operation=list&category=<?=$category?>&page='+this.value; return false;}" />
			</kbd>
		</div>
	</div>
	<?php } ?>



  </div>
</div>
</body>
</html>
